const express = require('express');
const app = express();
const url = require('url');

const vipData = require('./data/vip.json');
const adminData = require('./data/admin.json');

app.get('/login', (req, res) => {
  const user = url.parse(req.url, true).query.user;
  if (!user) {
    return res.send(JSON.stringify({ code: -1, success: false, msg: "缺少必要参数 user" }))
  }
  res.send(user === 'admin' ? adminData : vipData);
});
app.get('/favicon.ico', (req, res) => {
  res.send('');
});

app.listen(3000, () => {
  console.log('http://localhost:3000');
});
